package com.example.madman.yuejian.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.madman.yuejian.Bean.ClubBean;
import com.example.madman.yuejian.R;

import java.util.List;

/**
 * Created by Madman on 2018/10/10.
 */

public class OneClubAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private List<ClubBean> list2;
    private Context context;
    private LayoutInflater inflater;

    public OneClubAdapter(Context context) {
        this.inflater = LayoutInflater.from(context);
        this.context=context;
    }
    public void setList2(List<ClubBean> l){
        list2=l;
        notifyDataSetChanged();
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = inflater.inflate(R.layout.adapter_oneclub,parent,false);
        RecyclerView.ViewHolder vh = new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ClubBean bean = list2.get(position);
        if(bean==null) return;
        final ViewHolder viewHolder= (ViewHolder) holder;
        viewHolder.tel.setText(bean.getClubtel());

    }

    @Override
    public int getItemCount() {
        return list2.size();
    }
    @Override
    public long getItemId(int position) {
        return position;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
         TextView tel,address,info;
         ImageView club_show,back;

        public ViewHolder(View itemView) {
            super(itemView);
            tel = itemView.findViewById(R.id.text_clubtel);
            address = itemView.findViewById(R.id.text_clubaddress);
            info = itemView.findViewById(R.id.text_clubinfo);
            club_show = itemView.findViewById(R.id.image_dclub);
            back = itemView.findViewById(R.id.back);
        }
    }
}
